package com.java.array;

public class ArrayerfenDemo {
    public static int erfenfind(int[] array ,int num){
        int start = 0;
        int end = array.length-1;
        while(start <= end){
            int mid = (start+end)/2;
            if (num > array[mid]){
                start = mid+1;
            } else if (num < array[mid]) {
                end = mid-1;
            }
            else {
                return mid;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] arr = {12,23,34,56,67,89,99};
        int a = erfenfind(arr,89);
        System.out.println(a);
    }
}
